<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //原数组不变
        //slice(a,b) 截取字符串  slice()方法不会更改原数组    允许负数，表示倒数第几项
        var arr=['a','b','c','d','e','f','g']
        var arr_child1=arr.slice(2,5)
        console.log(arr)//不会改变 ['a','b','c','d','e','f','g']
        console.log(arr_child1)//子数组['c','d','e']

        var arr_child2 = arr.slice(2)
        console.log(arr_child2)//['c','d','e','f','g'] 从2到末尾

        var arr_child2 = arr.slice(2,-1)
        console.log(arr_child2)//['c','d','e','f'] 从2到倒数第2个
    </script>
</body>
</html>